<?php
/**
 * Container for datasource configuration
 * @author Artur Kmera <artur.kmera@3code.pl>
 * @version 0.9
 * @package ORM
 * @subpackage Schema
 * @link http://arrowplatform.org/orm
 * @copyright 2011 Arrowplatform 
 * @license GNU LGPL
*/
class Datasource {
	/**
	 * Connection string
	 * @var string
	 * @todo separate user and password ( currently in one string )
	 */
	public $connectionString;
	/**
	 * Connection encoding
	 * @var string
	 */
	public $charset;
	/**
	 * Is transaction on
	 * @var boolean
	 */
	public $transactions;
	
	/**
	 * Data source manager ( for synchronization and CRUD )
	 * @var string
	 * @todo Connect with synchonizer to autoload and using the right one
	 */
	public $manager;
	
	/**
	 * Connection holder 
	 * @var PDO
	 */
	public $connObj;
	
	
	/**
	 * Connecting with datasource
	 */
	public function connect(){
		$arr = explode(",", $this->connectionString);
		$this->connObj = new PDO( $arr[0], $arr[1], $arr[2] );
		$this->connObj->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
	}
	
	
	/**
	 * Returning connection object
	 * @return PDO
	 */
	public function getConnection(){
		return $this->connObj;
	}
}
?>